/**
 */
package org.xtext.context.aware.eventX.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.context.aware.eventX.EventXPackage;
import org.xtext.context.aware.eventX.Time;
import org.xtext.context.aware.eventX.WeekDayTime;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Week Day Time</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.context.aware.eventX.impl.WeekDayTimeImpl#getDay <em>Day</em>}</li>
 *   <li>{@link org.xtext.context.aware.eventX.impl.WeekDayTimeImpl#getTimeFrom <em>Time From</em>}</li>
 *   <li>{@link org.xtext.context.aware.eventX.impl.WeekDayTimeImpl#getTimeTo <em>Time To</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class WeekDayTimeImpl extends MinimalEObjectImpl.Container implements WeekDayTime
{
  /**
   * The default value of the '{@link #getDay() <em>Day</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDay()
   * @generated
   * @ordered
   */
  protected static final String DAY_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDay() <em>Day</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDay()
   * @generated
   * @ordered
   */
  protected String day = DAY_EDEFAULT;

  /**
   * The cached value of the '{@link #getTimeFrom() <em>Time From</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTimeFrom()
   * @generated
   * @ordered
   */
  protected Time timeFrom;

  /**
   * The cached value of the '{@link #getTimeTo() <em>Time To</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTimeTo()
   * @generated
   * @ordered
   */
  protected Time timeTo;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected WeekDayTimeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return EventXPackage.Literals.WEEK_DAY_TIME;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDay()
  {
    return day;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDay(String newDay)
  {
    String oldDay = day;
    day = newDay;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EventXPackage.WEEK_DAY_TIME__DAY, oldDay, day));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Time getTimeFrom()
  {
    return timeFrom;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTimeFrom(Time newTimeFrom, NotificationChain msgs)
  {
    Time oldTimeFrom = timeFrom;
    timeFrom = newTimeFrom;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EventXPackage.WEEK_DAY_TIME__TIME_FROM, oldTimeFrom, newTimeFrom);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTimeFrom(Time newTimeFrom)
  {
    if (newTimeFrom != timeFrom)
    {
      NotificationChain msgs = null;
      if (timeFrom != null)
        msgs = ((InternalEObject)timeFrom).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EventXPackage.WEEK_DAY_TIME__TIME_FROM, null, msgs);
      if (newTimeFrom != null)
        msgs = ((InternalEObject)newTimeFrom).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EventXPackage.WEEK_DAY_TIME__TIME_FROM, null, msgs);
      msgs = basicSetTimeFrom(newTimeFrom, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EventXPackage.WEEK_DAY_TIME__TIME_FROM, newTimeFrom, newTimeFrom));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Time getTimeTo()
  {
    return timeTo;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTimeTo(Time newTimeTo, NotificationChain msgs)
  {
    Time oldTimeTo = timeTo;
    timeTo = newTimeTo;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EventXPackage.WEEK_DAY_TIME__TIME_TO, oldTimeTo, newTimeTo);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTimeTo(Time newTimeTo)
  {
    if (newTimeTo != timeTo)
    {
      NotificationChain msgs = null;
      if (timeTo != null)
        msgs = ((InternalEObject)timeTo).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EventXPackage.WEEK_DAY_TIME__TIME_TO, null, msgs);
      if (newTimeTo != null)
        msgs = ((InternalEObject)newTimeTo).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EventXPackage.WEEK_DAY_TIME__TIME_TO, null, msgs);
      msgs = basicSetTimeTo(newTimeTo, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, EventXPackage.WEEK_DAY_TIME__TIME_TO, newTimeTo, newTimeTo));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case EventXPackage.WEEK_DAY_TIME__TIME_FROM:
        return basicSetTimeFrom(null, msgs);
      case EventXPackage.WEEK_DAY_TIME__TIME_TO:
        return basicSetTimeTo(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case EventXPackage.WEEK_DAY_TIME__DAY:
        return getDay();
      case EventXPackage.WEEK_DAY_TIME__TIME_FROM:
        return getTimeFrom();
      case EventXPackage.WEEK_DAY_TIME__TIME_TO:
        return getTimeTo();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case EventXPackage.WEEK_DAY_TIME__DAY:
        setDay((String)newValue);
        return;
      case EventXPackage.WEEK_DAY_TIME__TIME_FROM:
        setTimeFrom((Time)newValue);
        return;
      case EventXPackage.WEEK_DAY_TIME__TIME_TO:
        setTimeTo((Time)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case EventXPackage.WEEK_DAY_TIME__DAY:
        setDay(DAY_EDEFAULT);
        return;
      case EventXPackage.WEEK_DAY_TIME__TIME_FROM:
        setTimeFrom((Time)null);
        return;
      case EventXPackage.WEEK_DAY_TIME__TIME_TO:
        setTimeTo((Time)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case EventXPackage.WEEK_DAY_TIME__DAY:
        return DAY_EDEFAULT == null ? day != null : !DAY_EDEFAULT.equals(day);
      case EventXPackage.WEEK_DAY_TIME__TIME_FROM:
        return timeFrom != null;
      case EventXPackage.WEEK_DAY_TIME__TIME_TO:
        return timeTo != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (day: ");
    result.append(day);
    result.append(')');
    return result.toString();
  }

} //WeekDayTimeImpl
